#include <stdio.h>
#include "Course.h"
#include <time.h>
#include "../ModuleC/Log.h"
void ReadCImformation(){//通过键盘输入，录入课程信息
	if (headC != NULL) {
		printf("课程信息已录入，请不要反复录入！\n");
		return ;
	}
	int i;
	struct Course *p1;
	p1 = (struct Course *)malloc(sizeof(struct Course));
	printf("请输入课程编号，课程名，课程性质！\n");
	scanf("%s %s %s", p1->CNO, p1->CN, p1->CP);
	printf("请输入授课学时，学分，课程已选人数，课程人数上限！\n");
	scanf("%lf %lf %d %d", &p1->CT, &p1->CS, &p1->ASN, &p1->LSN); 
	printf("请输入已选课程学生名：\n");
	for(i = 0; i < p1->ASN; i++)
		scanf("%s", p1->CSN[i]);
	headC = p1;
	p1->next = NULL;
	while (1) {
		int num;
		printf("如果你想退出，请输入0，否则输入其他数字！\n");
		scanf("%d", &num);
	    	if (!num)
	    		break;
		p1 = (struct Course *)malloc(sizeof(struct Course));
		printf("请输入课程编号，课程名，课程性质！\n");
		scanf("%s %s %s", p1->CNO, p1->CN, p1->CP);
		printf("请输入授课学时，学分，课程已选人数，课程人数上限！\n");
		scanf("%lf %lf %d %d", &p1->CT, &p1->CS, &p1->ASN, &p1->LSN); 
		printf("请输入已选课程学生名：\n");
		for(i = 0; i < p1->ASN; i++)
			scanf("%s", p1->CSN[i]);
		p1->next = headC->next;
		headC->next = p1;
	}
	printf("录入课程信息成功！\n");
	FILE *fp1;	
	fp1=fopen("FILE/log.log","a");
	Log(fp1);
	fprintf(fp1,"通过键盘输入,录入了课程信息，调用了ReadCImformation()。\n");
	fclose(fp1);
}
